package server;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.jdom.JDOMException;

import refect.Refect;


import vo.Person;
import xml.JdomXml;


public class ActionServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		Person person = Refect.full(request);
	String message = "";
			Map<String, Person> persons;
			try {
				persons = JdomXml.jiexiXml("F:/Users/sss/Workspaces/MyEclipse 8.6/Test/src/resorce/user.xml");
				if(persons.get(person.getName()) != null){
					if(persons.get(person.getName()).getPassword().equals(person.getPassword())){
					message = "登录成功";
					}else {
					message = "密码输入错误";
					}
			}else {
				message = "用户不存在";
			}	
			} catch (JDOMException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			System.out.println(message);
		
	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doGet(request, response);
		
	}



}
